package com.woniuxy.utils;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.springframework.http.HttpStatus;

@Data
@NoArgsConstructor
@AllArgsConstructor
public class ResultVO {
    private String msg;
    private Integer code;
    private Object data;


    public ResultVO(Integer code,String msg){
        this.code=code;
        this.msg=msg;
    }
    public static ResultVO success(){
        return success("操作成功");
    }
    public  static ResultVO success(String msg){
        return success(msg,null);
    }
    public  static ResultVO success(String msg,Object data){
        return success(HttpStatus.OK.value(), msg,data);
    }
    public  static  ResultVO success(Integer code,String msg,Object data){
        ResultVO resultVO = new ResultVO();
        resultVO.setCode(code);
        resultVO.setMsg(msg);
        resultVO.setData(data);
        return resultVO;
    }

    public static  ResultVO fail(){
        return fail("操作失败");
    }
    public static  ResultVO fail(String msg){
        return fail(HttpStatus.INTERNAL_SERVER_ERROR.value(),msg);
    }
    public  static  ResultVO fail(Integer code,String msg){
        return fail(code,msg,null);
    }
    public static ResultVO fail(Integer code,String msg,Object data){
        ResultVO resultVO = new ResultVO();
        resultVO.setCode(code);
        resultVO.setMsg(msg);
        resultVO.setData(data);
        return  resultVO;
    }
}
